package com.example.interface_demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private LoginListenerUser mLoginListenerUser;
    private TextView mTextView;
    private int i=1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTextView = (TextView) findViewById(R.id.tv);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /**执行回调方法*/
                mLoginListenerUser.useLoginListener();
            }
        });


        /**创建类对象*/
        mLoginListenerUser = new LoginListenerUser();

        /**调用对象中的方法,传入回调方法*/
        mLoginListenerUser.setLoginListener(new LoginListener() {
            @Override
            public void showText() {
                mTextView.setVisibility(View.VISIBLE);
                mTextView.setText("天要下雨了");
                mTextView.setTextSize(30);

                Toast.makeText(MainActivity.this, "点击第"+i+"次", Toast.LENGTH_SHORT).show();
                i++;
            }
        });
    }

}
